import { h } from 'vue'
import UIconFont from '@/components/common/iconfont/IconFont.vue'
import { nullC  } from '@/util/common'
import { useBaseStore } from '@/store'
import { storeToRefs } from 'pinia'

// 格式化紧急程度的列表展示
// 其他主要用于显示的文字
export const formatEmergency = (text: string, otherMainText?: string) => {
  const { EMERGENCY_DEGREE } = storeToRefs(useBaseStore())
  let label = EMERGENCY_DEGREE.value.find((i: any) => i.value == text) || {}
  const icon: {[key: string] : string | any} = {
    "1": h(UIconFont, { type: 'icon-a-putong' }),
    "2": h(UIconFont, { type: 'icon-a-zhongyao' }),
    "3": h(UIconFont, { type: 'icon-jingji' }),
    "4": h(UIconFont, { type: 'icon-teji' }),
  }
  const iconColor: {[key: string] : string | any} = {
    "1": '#1890ff', "2": '#73D13D', "3": '#FFA940', "4": '#FF4D4F',
  }

  return h('div', [
    h(icon[text] ?? 'div', { style: { color: iconColor[text] ?? '' }}),
    h('span', { style: {color: iconColor[text] ?? '', marginLeft: '6px'}}, otherMainText ? otherMainText : nullC(label['label'])),
  ])
}